<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后台管理系统 - 登录</title>
    <link rel="stylesheet" href="{% static 'admin/style/bootstrap.min.css' %}">
    <link rel="stylesheet" href="{% static 'admin/style/login.css' %}"/>
    <script src="{% static 'admin/js/bootstrap.min.js' %}"></script>
    <script src="{% static 'admin/js/jquery.min.js' %}"></script>
</head>
<body>
<div class="login">
    <form name="form">
        <div class="title">
            超维度商城后台管理系统 - 登录
        </div>
        <div class="mb-3">
            <label class="form-label">用户名</label>
            <input type="text" name="user_name" class="form-control" placeholder="Username" required autocomplete="off">
        </div>
        <div class="mb-3">
            <label class="form-label">密码</label>
            <input type="password" name="user_pass" class="form-control" placeholder="Password" required autocomplete="off">
        </div>
        <div style="text-align: center">
            <button type="button" onclick="login()" class="btn btn-primary">登  录</button>
        </div>
    </form>
</div>
</body>
<script>
    function login(){
        let user_name = $("input[name='user_name']").val();
        let user_pass = $("input[name='user_pass']").val();
        $.post(
            'auth/login/',
            {'user_name':user_name,'user_pass':user_pass},
            function (res){
                if(res.code===200){
                    alert('登录认证成功！')
                    window.location.reload()
                }else{
                    alert(res.message)
                }
            },'json'
        )
    }

</script>
</html>
